﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WEPMlibrary_Model;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace WEPMconnection_DAL
{
    public class JurisdictionDal
    {

        Conntion Con = new Conntion();
        /// <summary>
        /// 登录权限显示
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public List<Jurisdiction> JurisdictionShow(string name,string pwd)
        {
            SqlConnection conn = Con.Con();
            StringBuilder str = new StringBuilder();
            str.AppendLine("select * from Jurisdiction where Id in(  ");
            str.AppendLine(" select Rid from RoleRight where  Uid=( ");
            str.AppendLine(" select Rid from UserInfor where UserName='"+name+"'");
            str.AppendLine(" and UserPwd='"+pwd+"'))");
            SqlDataAdapter adapter = new SqlDataAdapter(str.ToString(),conn);
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            List<Jurisdiction> list = new List<Jurisdiction>();
            foreach (DataRow dr in dt.Rows)
            {
                Jurisdiction j = new Jurisdiction();
                j.DisplayOrder = Convert.ToInt32(dr["DisplayOrder"]);
                j.Id = Convert.ToInt32(dr["Id"]);
                j.JurisdName = dr["JurisdName"].ToString();
                j.JurisdUrl = dr["JurisdUrl"].ToString();
                j.ParentNodeId = Convert.ToInt32(dr["ParentNodeId"]);
                list.Add(j);
            }
            return list;
        }
      
    }
}
